﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using AppleAutoBuy.Common;
using SHDocVw;
using mshtml;

namespace AppleAutoBuy
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void StartButton_Click(object sender, EventArgs e)
        {
            AppleBrowserOperator appleOperator = new AppleBrowserOperator();
            appleOperator.Start(ResourceManager.AppleData.StartUrl, null);  
        }

        void ie_ThirdPartyUrlBlocked(ref object URL, uint dwCount)
        {
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //comboBox1.Focus();
            //Util.SetState(VirtualKeys.VK_DOWN, true);
            //Util.SetState(VirtualKeys.VK_DOWN, false); 
            IntPtr hwnd= IntPtr.Zero;
            IHTMLDocument2 doc2 = Util.GetIDoc2FromTitle("Test", out hwnd);

        }

        #region Assist

        public mshtml.IHTMLDocument2 getIEWindowDocument(string windowName)
        { 
            //开始查找指定的ie窗体 
            int hwnd = Win32APIUnsafe.FindWindow("Internet Explorer_Server", windowName);
            mshtml.IHTMLDocument2 doc = Util.GetIDoc2FromHandle(new IntPtr(hwnd));

            //MessageBox.Show(doc.toString()); 
            MessageBox.Show("到这里2");
            MessageBox.Show(doc.url);
            MessageBox.Show(doc.title);

            return doc;
        }   

        #endregion

    }
}
